package com.pratices.mvc.servlet;

import com.pratices.cookie.bean.BaseRespVo;
import com.pratices.mvc.data.PageInfo;
import com.pratices.mvc.jedis.JedisDemo;
import com.pratices.mvc.service.AdminRegionService;
import com.pratices.mvc.servlet.common.CommonServlet;
import com.pratices.mvc.util.ServiceHolder;


import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/admin/region/*")
public class AdminRegionServlet extends CommonServlet {
    //获取service单例
    AdminRegionService adminRegionService = ServiceHolder.getService(AdminRegionService.class);
    //list方法
    public BaseRespVo list(HttpServletRequest req, HttpServletResponse resp){
        //调用service层方法
        PageInfo pageInfo = adminRegionService.list(req, resp);
        //此时调用JedisDemo里的存放方法，把数据存到redis中
        JedisDemo.set("region", pageInfo);
        return BaseRespVo.ok(pageInfo);
    }
}
